﻿#region Copyright (C) Sector7 Software Studio. All rights reserved
/*******************************************************************************************
 * Creation
 *      Author:         Wolf Lai
 *      Date:           2013/12/4 星期三 21:54:38
 *      Version:        
 * Modification 
 *      Author: 
 *      Date: 
 *      Description: 
 *      Version:
 *******************************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using Sector7.Framework.Utility;
using Sector7.Medical.Consts;
using System.IO;

namespace Sector7.Medical.Utility
{
    /// <summary>
    /// 界面工具类
    /// </summary>
    public class InterfaceUtil
    {
        #region Public functions

        /// <summary>
        /// 获取默认头像
        /// </summary>
        /// <returns></returns>
        public static BitmapImage GetDefaultAvatar()
        {
            string avatarPath = PathUtil.GenerateAbsPath(C_PathName.DIR_IMAGES, C_PathName.FILE_DEFAULT_AVATAR);

            BitmapImage avatar = null;
            if (File.Exists(avatarPath))
            {
                avatar = new BitmapImage(new Uri(avatarPath));
            }

            return avatar;
        }

        /// <summary>
        /// 获取公民头像
        /// </summary>
        /// <param name="citizenId">公民唯一标识符</param>
        /// <returns></returns>
        public static BitmapImage GetAvatar(string citizenId)
        {
            string avatarPath = PathUtil.GenerateAbsPath(C_PathName.DIR_USER_DATA, citizenId, C_PathName.FILE_AVATAR);

            BitmapImage avatar = null;
            if (File.Exists(avatarPath))
            {
                avatar = new BitmapImage(new Uri(avatarPath));
            }
            else
            {
                avatar = GetDefaultAvatar();
            }

            return avatar;
        }

        #endregion

        #region Private functions
        #endregion
    }
}
